﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using DevExpress.XtraEditors;
using RFIDStockManagement.BLL;
using RFIDStockManagement.Model.Public;

namespace RFIDStockManagement.Client
{
    public partial class AddStockCheckSegmentForm : XtraForm
    {
        private StockCheckManager _thisManager;
        private StockCheckInfo retVal;

        public StockCheckInfo RetValue
        {
            get { return retVal; }
            set { retVal = value; }
        }


        public AddStockCheckSegmentForm(StockCheckManager thisDb)
        {
            InitializeComponent();
            _thisManager = thisDb;
            retVal = new StockCheckInfo();
            retVal.FId = -1;

        }

        public StockCheckInfo AddNewInfoShow()
        {
            retVal.FId = -1;
            this.txtCaption.Text = string.Empty;
            this.txtNote.Text = string.Empty;

            this.ShowDialog();

            return retVal;

        }

        private void bntOk_Click(object sender, EventArgs e)
        {
            if(string.IsNullOrEmpty(this.txtCaption.Text.Trim()))
            {
                AlertForm.ShowError("盘点周期名称必须录入");
                return;
            }


            int ret = _thisManager.AddNewCheckSegment(this.txtCaption.Text.Trim(), this.txtNote.Text.Trim());

            retVal.FId = ret;

            this.Hide();
        }

        private void bntCancel_Click(object sender, EventArgs e)
        {
            retVal.FId = -1;
            this.Hide();
        }


    }
}
